package com.base.myproject.client.ui;

import com.base.myproject.client.busi.print.Print;
import com.base.myproject.client.busi.print.PrintInfo;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;

public class PrintDialog extends Dialog implements Listener{
	
	PrintInfo pi =null;
   
    
	public PrintDialog(PrintInfo pi)
	{
		this.pi=pi;
		init();
	}
	public PrintDialog(String doc,String css,String html)
	{
		init();
		super.show();
		Print.it(doc,css,html);

	}
	
	public void init()
	{
		setHeading("打印");  
	    setButtons(Dialog.YESNO);  
	    setBodyStyleName("pad-text");  
	    setScrollMode(Scroll.AUTO);  
	    //setHideOnButtonClick(true);  
	    ContentPanel panel = new ContentPanel(); 

	   
	    setLayout(new RowLayout(Orientation.HORIZONTAL));  
	    com.extjs.gxt.ui.client.widget.FramePanel frame =  com.extjs.gxt.ui.client.widget.FramePanel.pop();  

	 
	    frame.setId("__printingFrame");

	    
	    this.add(frame,new RowData(1, 1));

	    this.setSize(360, 420);

	    
	    this.getButtonById(Dialog.YES).addListener(Events.Select, this);
	    this.getButtonById(Dialog.NO).addListener(Events.Select, this);
	 
	}
	public void show()
	{
		super.show();
	//	Print.it("","","<div  style=\"word-wrap: break-word; word-break: normal; width:200px \" ><a >asadfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf2222222222222222222222dfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdfdf</a></div>");
//		Print.it("sssssssssssss");
	}

	@Override
	public void handleEvent(BaseEvent be) {
		// TODO Auto-generated method stub
		
		if(be.getSource().equals(this.getButtonById(Dialog.NO)))
		{
			this.hide();
		}
		else if(be.getSource().equals(this.getButtonById(Dialog.YES)))
		{
			
//			if(list1.getSelectedItem()==null)
//			{
//				MessageBox.alert("错误", "未选择打印格式", null);
//				return;
//			}
				//Print.it("未处理");
			Print.printFrame();
		}
		
	}

}
